<template lang="html">
	<div class="Signin_box">
		<img src="../../assets/img/banner/banenr_1.png" class="Signin_img">
		<form class="Signin_form">
			<i class="account_icon"></i>
			<input type="search" name="account" class="" placeholder="登录账号">
			<i class="pwd_icon"></i>
			<input type="password" name="pwd" placeholder="登录密码">
			<div class="Signin_btn" v-on:click="say()">登录</div>
			<div class="Signin_Other">
				<router-link class="forget_pwd" to="/"><i class="icon_forget"></i>忘记密码</router-link>
				<router-link class="wcloggede" to="/register"><i class="icon_wxld"></i>微信登录</router-link>
			</div>
		</form>
	</div>
</template>
<script type="text/javascript">
	export default {
	  name: 'Signin',
	  data(){
	  	return{
	  	}
	  },
	  methods:{
	    say:function(){
		    let account = document.getElementsByName("account")[0],
		    pwd = document.getElementsByName("pwd")[0],
		    self = this;
		    var qs = require('querystring');
	      	if(!account.value){
	      		this.$toast('账号不能为空！');
	      		return false;
	      	}
	      	if (!pwd.value) {
	      		this.$toast('密码不能为空！');
	      		return false;
	      	}
	      	self.$loading('登录中');
		    var _url="http://192.168.1.61/newshengjigongsisvn/php//index.php?g=app&m=shopping&a=login_post"; 
		    var _data={
		    	user_login:account.value,
		    	user_pass:pwd.value
		    }
		    self.ajxashuju({
			    method: 'POST',
			    url: _url,
			    data: _data,
			    success: function (response) {
			    	response = JSON.parse(response);
			       if(response.status=="1"){
						self.$toast('登录成功');
						sessionStorage.setItem("cur_id",response.cur_id);  
		        		sessionStorage.setItem("sign",response.sign);
						window.setTimeout(function(){
							window.location.href = "index.html";
						},1500)
			       }else {
			       		self.$loading.close();
			       		self.$toast(response.info);
			       }
			    }
			});
	    },
	    ajxashuju:function(opt){
	    	opt = opt || {};
	        opt.method = opt.method.toUpperCase() || 'POST';
	        opt.url = opt.url || '';
	        opt.async = opt.async || true;
	        opt.data = opt.data || null;
	        opt.success = opt.success || function () {};
	        var xmlHttp = null;
	        if (XMLHttpRequest) {
	            xmlHttp = new XMLHttpRequest();
	        }
	        else {
	            xmlHttp = new ActiveXObject('Microsoft.XMLHTTP');
	        }
	        var params = [];
	        for (var key in opt.data){
	            params.push(key + '=' + opt.data[key]);
	        }
	        var postData = params.join('&');
	        if (opt.method.toUpperCase() === 'POST') {
	            xmlHttp.open(opt.method, opt.url, opt.async);
	            xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded;charset=utf-8');
	            xmlHttp.send(postData);
	        }
	        else if (opt.method.toUpperCase() === 'GET') {
	            xmlHttp.open(opt.method, opt.url + '?' + postData, opt.async);
	            xmlHttp.send(null);
	        } 
	        xmlHttp.onreadystatechange = function () {
	            if (xmlHttp.readyState == 4 && xmlHttp.status == 200) {
	                opt.success(xmlHttp.responseText);
	            }
	        };
		}
	  },
	  components:{

	  }
	}
</script>

<style scoped lang="less">
	@import '../../assets/less/index.less';
	.Signin_box{

	}
</style>